{$layout}
{$template "/proxy/menu"}


<!-- 检测配置更新 -->
<proxy-change-notify-box></proxy-change-notify-box>

<div class="ui menu text blue small" v-if="locationId.length == 0">
	<a :href="'/proxy/backend?serverId=' + server.id + '&locationId=' + locationId" class="item">服务器列表</a>
	<a :href="'/proxy/groups?serverId=' + server.id" class="item active">分组管理</a>
	<a :href="'/proxy/groups/add?serverId=' + server.id" class="item">添加分组</a>
</div>

<div class="ui menu text blue small" v-if="locationId.length > 0 && websocket == '0'">
	<a :href="'/proxy/locations/backends?serverId=' + server.id + '&locationId=' + locationId" class="item">服务器列表</a>
	<a :href="'/proxy/groups?serverId=' + server.id+ '&locationId=' + locationId" class="item active">分组管理</a>
	<a :href="'/proxy/groups/add?serverId=' + server.id+ '&locationId=' + locationId" class="item">添加分组</a>
</div>

<div class="ui menu text blue small" v-if="locationId.length > 0 && websocket == '1'">
	<a :href="'/proxy/locations/websocket?serverId=' + server.id + '&locationId=' + locationId + '&websocket=1'" class="item">服务器列表</a>
	<a :href="'/proxy/groups?serverId=' + server.id+ '&locationId=' + locationId + '&websocket=1'" class="item active">分组管理</a>
	<a :href="'/proxy/groups/add?serverId=' + server.id+ '&locationId=' + locationId + '&websocket=1'" class="item">添加分组</a>
</div>

<div class="ui divider" style="margin-bottom:1em!important;"></div>

<p class="comment" v-if="groups.length == 0">暂时还没有分组。</p>

<table class="ui table selectable" v-if="groups.length > 0">
	<thead>
		<tr>
			<th>分组名称</th>
			<th style="width:15em">匹配条件</th>
			<th style="width:15em">IP范围</th>
			<th class="two op">操作</th>
		</tr>
	</thead>
	<tr v-for="group in groups">
		<td>{{group.name}}<br/>
			<span v-if="group.id == 'default'" class="ui label tiny" style="margin-top:0.4em;padding:4px;font-size:0.6em">默认分组</span>
		</td>
		<td>
			<span v-if="group.conds == null || group.conds.length == 0" class="disabled">-</span>
			<div v-if="group.conds != null" v-for="cond in group.conds" style="margin-top:0.3em;margin-bottom:0.3em">
				<span class="ui label tiny">{{cond.param}} <var>{{cond.operator}}</var> {{cond.value}}</span>
			</div>
		</td>
		<td>
			<span v-if="group.ipRanges == null || group.ipRanges.length == 0" class="disabled">-</span>
			<div v-if="group.ipRanges != null" v-for="ipRange in group.ipRanges" style="margin-top:0.3em;margin-bottom:0.3em">
				<span class="ui label tiny" v-if="ipRange.type == 1" style="line-height:1.5">{{ipRange.param}} {{ipRange.ipFrom}} - {{ipRange.ipTo}}</span>
				<span class="ui label tiny" v-if="ipRange.type == 2" style="line-height:1.5">{{ipRange.param}} {{ipRange.cidr}}</span>
			</div>
		</td>
		<td>
			<a :href="'/proxy/groups/update?serverId=' + server.id + '&locationId=' + locationId + '&groupId=' + group.id + '&websocket=' + websocket">修改</a> &nbsp;
			<a href="" @click.prevent="deleteGroup(group.id)" v-if="group.id != 'default'">删除</a>
		</td>
	</tr>
</table>